{template 'common/header'}
<script>
    require(['jquery', 'angular', 'util', 'underscore'], function($, angular, u, _){
        $(function(){
            angular.module('app', []).controller('formPanel', function($scope, $http) {
                $scope.type = "{$entity['type']}";
                {if $entity['type'] == 'cash'}
                $scope.cash = {php echo json_encode($entity['tag'])};
                {else}
                $scope.cash = {};
                {/if}
                    
                $scope.submit = function() {
                    var message = '';
                    if($.trim($(':text[name=replace]').val()) == '') {
                        message += '必须输入替换参数 <br>';
                    }
                    if($.trim($(':text[name=name]').val()) == '') {
                        message += '必须输入参数值 <br>';
                    }
                    if(message) {
                        u.message(message);
                    } else {
                        $('#theform')[0].submit();
                    }
                };
            });
            angular.bootstrap(document, ['app']);
        });
    });

</script>
<div class="clearfix">
    <form id="theform" class="form form-horizontal ng-cloak" action="" method="post" ng-controller="formPanel">
        <div class="panel panel-default">
            <div class="panel-heading">
                参数基本信息
            </div>
            <div class="panel-body">
                <div class="form-group">
                    <label class="col-sm-2 control-label">替换参数</label>
                    <div class="col-sm-5">
                        <input class="form-control" type="text" name="replace" value="{$setting['replace']}"/>
                        <div class="help-block">
                            替换参数，要替换的部分，定义时 用##包裹，例如 #用户昵称#
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">参数值</label>
                    <div class="col-sm-5">
                        <input class="form-control" type="text" name="name" value="{$setting['name']}"/>
                        <div class="help-block">
                            参数值，替换成的部分，填写数据表中的字段
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">参数用法</label>
                    <div class="col-sm-8">
                        <textarea style="height:150px;" class="richtext-clone" name="pro" >{$setting['pro']}</textarea>
                        <div class="help-block">
                            介绍下参数的用法
                        </div>
                        <script type="text/javascript">
                            require(['jquery', 'util'],function($, util){
                                window.editor = util.editor($('.richtext-clone')[0]);
                            })
                        </script>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label"></label>
                    <div class="col-md-2 col-lg-1">
                        <input type="button" value="保存" class="btn btn-primary btn-block" ng-click="submit();" />
                    </div>
                </div>
            </div>
        </div>
    </form>
</div>
{template 'common/footer'}
